const echarts = require('echarts/lib/echarts')

// 饼图配置
export const pieOption = (data) => {
  return {
    tooltip: {
      trigger: 'item',
      confine: true,//将此权限打开后tooltip将不再溢出
    },
    color: ['#00D1FF', '#FFAD30'],
    legend: {
      right: '25%',
      top:'20%',  
      icon: 'circle',
      orient: 'vertical',
      textStyle:{
        color:['#00D1FF', '#FFAD30']
      }
    },
    series: [
      {
        name: '巡检进度',
        type: 'pie',
        radius: ['45%', '60%'],
        center: ['20%', '45%'],
        data,
        label: {
          fontSize: 14,
          position: 'center',
          formatter: function (params) { // 默认显示第一个数据
            if (params.dataIndex === 0) {
              return '{nm|' + params.name + '}'+'\n{p|' + params.percent + '%}' 
            } else {
              return ''
            }
          },
          emphasis: {
            formatter: function (params) {
              if (params.dataIndex != 0) {
                return '{nm|' + params.name + '}'+'\n{p|' + params.percent + '%}' 
              }
            },
          },
          rich: {
            p: {
              // fontSize: 16,
              backgroundColor: "#001425" // 覆盖index=0时的数据
            },
            nm: {
              // color: '#333',
              // fontSize: 14,
              backgroundColor: "#001425" // 覆盖index=0时的数据
            }
          }
        },
        emphasis: {
          label: {
            show: true,
            fontSize: '12',
            fontWeight: 'bold',
          },
        },
        labelLine: {
          show: false
        },

      }
    ]
  }
}